package com.jzo2o.customer.controller.worker;

import com.jzo2o.common.model.CurrentUserInfo;
import com.jzo2o.common.utils.BeanUtils;
import com.jzo2o.customer.model.domain.BankAccount;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.request.ServeSkillAddReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.model.dto.response.EvaluationAndOrdersResDTO;
import com.jzo2o.customer.service.BankAccountService;
import com.jzo2o.customer.service.EvaluationService;
import com.jzo2o.mvc.utils.UserContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 评价相关接口
 *
 * @author itcast
 * @create 2023/9/11 16:14
 **/
@RestController("workerBankAccountController")
@RequestMapping("/worker/bank-account")
@Api(tags = "服务端 - 银行账号相关接口")
public class BankAccountController {
    @Resource
    private BankAccountService bankAccountService;

    @PostMapping
    @ApiOperation("新增或更新银行账号信息")
    public void updateBankAccountInfo(@RequestBody BankAccountUpsertReqDTO
                                                  bankAccountUpsertReqDTO) {
        //没有想到怎么确定是服务人员还是服务机构
        CurrentUserInfo currentUserInfo = UserContext.currentUser();
        bankAccountUpsertReqDTO.setId(currentUserInfo.getId());
        bankAccountUpsertReqDTO.setType(currentUserInfo.getUserType());
        bankAccountService.updateBankAccountInfo(bankAccountUpsertReqDTO);
    }


    @GetMapping("/currentUserBankAccount ")
    @ApiOperation("获取当前用户银行账号")
    public BankAccountResDTO getBankAccount() {
//        注意BankAccount里面的id就是当前用户的id
        CurrentUserInfo currentUserInfo = UserContext.currentUser();

        BankAccount bankAccount = bankAccountService.getBankAccount(currentUserInfo.getId());
        return BeanUtils.toBean(bankAccount, BankAccountResDTO.class);
    }




}
